<!DOCTYPE HTML><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $title ?></title>
<? require("lib.php"); ?>
<style>
.fileer { padding: 5px 0; }
</style>
</head>
<body>
  <div class="content-box">
    <div class="content-box-header">
      <h3><? echo $title ?></h3>
      <div class="clear"></div>
    </div> <!-- .content-box-header -->
    <div class="content-box-content">
<?
switch ($do) {
  case "add":
  add();
  break;
  case "update":
  update($uid);
  break;
  case "delete":
  delete($id);
  break;
  default:	
  show_info($info);
}
?>
<? function show_box($row, $iseditmode, $isadd){ 
	global $id, $cate, $baseurl, $h, $cateid, $gee, $product_name, $url, $title;
?>
<!--图片上传-->
<script type="text/javascript">
var pi = 0;
var pj = 12;
$(function() {
    $("#addpic").click(function(){
        if (pi < pj){
            pi = pi + 1;
            //$("#addpic").text(pj - pi);
            var fid = "cpic" + pi;
            $("#pic").after("<div id='"+fid+"' class='fileer'><input type='file' name='" + fid + "' class='g' /> <a href=\"javascript:rmfile('" + fid + "')\" >- <?=ROOT_DELETE?></a><div>");
        }
    })
})
rmfile = function(fn) {
    var filename = "#" + fn;
    $("div").remove(filename);
    pj = pj + 1;
    //$("#imgNum").text(pj - pi);
};
</script>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
    <tr class="th"><td class="thtitle" width="148" align="right"><? echo $title ?></td>
      <td>
        <? echo $h->hidden('id', $row["id"]); ?>
        <? echo $h->hidden('cid', $cateid); ?></td></tr>
        <tr><td class="l"></td><td><span class="red"> <?=ROOT_PICTURE_SIZE_RATIO?><? echo PRODUCT_LARGE_PIC_WIDTH.':'.PRODUCT_LARGE_PIC_HEIGHT ?>.</span></td></tr>
      <tr><td class="l"><?=ROOT_PRODUCT?></td><td><input value="<? echo $product_name ?>" class="g" disabled /></td></tr>
      <tr><td class="l"><?=ROOT_PICTURE?></td><td>
      <div id="pic" class="fileer"><input type="file" name="cpic0" class="g" /> <a id="addpic"><?=ROOT_ADD_PICTURE?></a></div>
      </td></tr>
      <tr><td class="l"> </td><td><br><? echo $h->submit('save', '&nbsp; '.ROOT_SAVE.' &nbsp;', $iseditmode==1?'':'hide') ?>&nbsp; <a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
    </table>
    <? } ?>
	<? function show_boxes($result){ 
		global $url, $pages, $s, $lang, $baseurl, $page, $cate, $cateid, $product_name, $total_pics;
		$str= '<table width="99%" cellspacing="0" cellpadding="3" class="mlist" id="picbox"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_PRODUCT.'</strong></td><td><strong>'.ROOT_PICTURE.'</strong></td>';
		$str.='<td>';
		if($total_pics<MAX_PHOTO_PER_PRODUCT_ALLOW) {
			$str.='<a href="'.$url.'.php?do=add&cid='.$cateid.'">[ '.ROOT_ADD.' ]</a>';
		}
		else {
			$str.='[ '.ROOT_PRODUCT_PIC_UPLOAD_QUANTITY_REACH_MAX_LIMIT.' ]';
		}
		$str.='</td>';
		$str.='</tr>';
		$count=1;
    foreach( $result as $row)
		{
			$id=$row['id'];
      $str.="<tr><td>".$row['id'].".</td><td>".$product_name."</a></td><td><img src='".PRODUCT_PIC_HOST.$row['small_pic']."' height='50' /></td><td>";
			$str.="<a href=\"$url.php?do=delete&cid=".$cateid."&id=".$id."\" onClick=\"return delc();\">".ROOT_DELETE."</a></td></tr>";
			$count++;
		}
		$str.= "</table>";
		if($count==1) $str.= "<br>".ROOT_NO_DATA."!";
    echo $str;
    //echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
     } ?>
     <br class="clear" />
   </div> <!-- .content-box-content -->
   <br class="clear" />
 </div><!-- .content-box -->
</body>
</html>